package jee.boot.module.authority.rest;

import jee.boot.common.basic.CrudController;
import jee.boot.common.basic.result.ResponseMessage;
import jee.boot.common.basic.result.Result;
import jee.boot.module.authority.service.AuthorityService;
import jee.boot.entity.auth.Authority;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 原子权限
 */
@RestController
@RequestMapping(value = "/authority")
public class AuthorityController extends CrudController<AuthorityService, Authority> {

    /**
     * 更新权限配置
     *
     * @param entity
     * @return
     */
    @PostMapping("/updateResourceList")
    public ResponseMessage<Authority> updateResourceList(@RequestBody Authority entity) {
        service.updateResourceList(entity);
        return Result.success(entity);
    }
    /**
     * 更新权限配置
     *
     * @param entity
     * @return
     */
    @PostMapping("/updateTreeNodeList")
    public ResponseMessage<Authority> updateTreeNodeList(@RequestBody Authority entity) {
        service.updateTreeNodeList(entity);
        return Result.success(entity);
    }
    /**
     * 复制权限配置
     *
     * @param entity
     * @return
     */
    @PostMapping("/copy")
    public ResponseMessage<Authority> copy(@RequestBody Authority entity) {
        service.copy(entity);
        return Result.success(entity);
    }
}
